{template 'header'}
<body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">金融管理</a>
        <a>
          <cite>提现列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
         href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" id="search">
          提现时间:
          <input class="layui-input" autocomplete="off" placeholder="开始日" name="start_time" id="start_time"
                 value="{$_GPC['start_time']}">
          <input class="layui-input" autocomplete="off" placeholder="截止日" name="end_time" id="end_time"
                 value="{$_GPC['end_time']}">
          提现者ID:
          <input type="text" name="user_id" placeholder="提现人ID/手机号" autocomplete="off" class="layui-input" id="user_id"
                 value="{$user_id}">
          提现状态:
          <div class="layui-input-inline">
            <select name="logtype">
              <option value="" {if $logtype==''}selected{/if}>请选择提现状态</option>
              <option value="-1" {if $logtype=='-1'}selected{/if}>驳回</option>
              <option value="1" {if $logtype=='1'}selected{/if}>通过</option>
              <option value="0" {if $logtype=='0'}selected{/if}>待处理</option>
            </select>
          </div>
          <button class="layui-btn" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
        <button class="layui-btn" onclick="cashoutAll(1)">
          <i class="layui-icon">&#xe6af;</i>批量通过
        </button>
        <button class="layui-btn" onclick="cashoutAll(0)">
          <i class="layui-icon">&#xe69c;</i>批量驳回
        </button>
        <span class="x-right" style="line-height:40px">共有数据：{$total} 条</span>
      </xblock>
      <table class="layui-table x-admin">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i
                      class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>提现者ID</th>
            <th>提现金额</th>
            <th>提现手续费</th>
            <th>提现人备注</th>
            <th>状态</th>
            <th>提现时间</th>
            <th>处理时间</th>
            <th>处理人ID</th>
            <th>操作</th>
            </tr>
        </thead>
        <tbody>
        {if $total==0}

        <tr>
          <td colspan="11" style="text-align: center;">暂无数据</td>
        </tr>

        {else}
        {loop $list $item}
          <tr>
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$item["id"]}'><i
                      class="layui-icon">&#xe605;</i></div>
            </td>
            <td>{$item["id"]}</td>
            <td>{$item["user_id"]}</td>
            <td>{$item["cash_money"]}</td>
            <td>{$item["tx_fee"]}</td>
            <td>{$item["tx_mark"]}</td>
            <td>
              {if $item['cash_status'] == '0'}
              <span style="color: blue">待处理</span>
              {elseif $item['cash_status'] == '-1'}
              <span style="color: red">驳回</span>
              {elseif $item['cash_status'] == '1'}
              <span style="color: green">通过</span>
              {/if}
            </td>
            <td>{php echo date('Y-m-d H:i:s',$item["create_time"])}</td>
            <td>{php echo date('Y-m-d H:i:s',$item["handle_time"])}</td>
            <td>{$item["handle_id"]}</td>
            <td>
                <a title="通过" onclick="cashout(this,{$item['id']},1)" href="javascript:;">
                  <i class="layui-icon">&#xe6af;</i>
                </a>
                <a title="驳回" onclick="cashout(this,{$item['id']},0)" href="javascript:;">
                  <i class="layui-icon">&#xe69c;</i>
                </a>
            </td>
          </tr>
        {/loop}
        {/if}
        </tbody>
      </table>
      <div class="page">
        {$pager}
      </div>

    </div>
    <script>
      layui.use('form', function () {
        var form = layui.form;

        //监听提交
        form.on('submit(search)', function (data) {
          console.log(data.field)
          var str = '';
          for (var key in data.field) {
            str += key + "=" + data.field[key] + "&";
          }
          var url = '{php echo $this->createWebUrl("cashout_list")}'
          location.href = url + "&" + str;
          return false;
        });
      });

      function exportUser(){
        var str = $('#search').serialize()
        var ids = tableCheck.getData();
        var url = '{php echo $this->createWebUrl("")}'
        location.href = url + "&" + str + "&ids=" + ids;
      }

      layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
          elem: '#start_time', //指定元素
          type: 'datetime'
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end_time', //指定元素
          type: 'datetime'
        });
      });

    </script>
    <script>
      function cashout(obj,id, yes) {
        var data = {id, yes}
        if (yes == 0) {
          layer.prompt({title: '驳回理由', formType: 2}, function(text, index){
            layer.close(index);
            data.cash_mark = text
            var url = '{php echo $this->createWebUrl("cashout_list",["op"=>"cashout"])}'
            $.post(url, data, function (ret) {
              if (ret.code) {
                layer.msg(ret.msg, {icon: 1, time: 1000},function () {
                  location.reload();
                });
              } else {
                layer.msg(ret.msg, {icon: 0});
              }
            }, 'json')
          });
        }else{
          var url = '{php echo $this->createWebUrl("cashout_list",["op"=>"cashout"])}'
          $.post(url, data, function (ret) {
            if (ret.code) {
              layer.msg(ret.msg, {icon: 1, time: 1000},function () {
                location.reload();
              });
            } else {
              layer.msg(ret.msg, {icon: 0});
            }
          }, 'json')
        }
      }

      function cashoutAll(yes) {
        var ids = tableCheck.getData();
        var data = {ids, yes}
        if (yes == 0) {
          layer.prompt({title: '驳回理由', formType: 2}, function(text, index){
            layer.close(index);
            data.cash_mark = text
            var url = '{php echo $this->createWebUrl("cashout_list",["op"=>"cashout"])}'
            $.post(url, data, function (ret) {
              if (ret.code) {
                layer.msg(ret.msg, {icon: 1, time: 1000},function () {
                  location.reload();
                });
              } else {
                layer.msg(ret.msg, {icon: 0});
              }
            }, 'json')
          });
        }else{
          var url = '{php echo $this->createWebUrl("cashout_list",["op"=>"cashout"])}'
          $.post(url, data, function (ret) {
            if (ret.code) {
              layer.msg(ret.msg, {icon: 1, time: 1000},function () {
                location.reload();
              });
            } else {
              layer.msg(ret.msg, {icon: 0});
            }
          }, 'json')
        }
      }
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>